package com.umeng.analytics.social;

import android.content.Context;
import android.os.AsyncTask;
import android.text.TextUtils;

import org.json.JSONObject;

public abstract class UMSocialService {
    static class a extends AsyncTask {
        String a;
        String b;
        b c;
        UMPlatformData[] d;

        public a(String[] arg2, b arg3, UMPlatformData[] arg4) {

            this.a = arg2[0];
            this.b = arg2[1];
            this.c = arg3;
            this.d = arg4;
        }

        protected c a(Void[] arg5) {
            c v0_3;
            int v1;
            int v0_2;
            JSONObject v2;
            String v0 = TextUtils.isEmpty(this.b) ? com.umeng.analytics.social.b.a(this.a) : com.umeng.analytics.social.b.a(this.a, this.b);
            try {
                v2 = new JSONObject(v0);
                v0_2 = v2.optInt("st");
                if (v0_2 == 0) {
                    v1 = -404;
                } else {
                    v1 = v0_2;
                }

                v0_3 = new c(v1);
                String v1_1 = v2.optString("msg");
                if (!TextUtils.isEmpty(((CharSequence) v1_1))) {
                    v0_3.a(v1_1);
                }

                v1_1 = v2.optString("data");
                if (TextUtils.isEmpty(((CharSequence) v1_1))) {
                    return v0_3;
                }

                v0_3.b(v1_1);
            } catch (Exception v0_1) {
                v0_3 = new c(-99, v0_1);
            }

            return v0_3;
        }

        protected void a(c arg3) {
            if (this.c != null) {
                this.c.a(arg3, this.d);
            }
        }

        protected Object doInBackground(Object[] arg2) {
            return this.a(((Void[]) arg2));
        }

        protected void onPostExecute(Object arg1) {
            this.a(((c) arg1));
        }

        protected void onPreExecute() {
            if (this.c != null) {
                this.c.a();
            }
        }
    }

    public interface b {
        void a(c arg1, UMPlatformData[] arg2);

        void a();
    }

    public UMSocialService() {

    }

    private static void a(Context arg3, b arg4, String arg5, UMPlatformData[] arg6) {
        int v0 = 0;
        if (arg6 != null) {
            try {
                int v1 = arg6.length;
                while (v0 < v1) {
                    if (!arg6[v0].isValid()) {
                        throw new com.umeng.analytics.social.a("parameter is not valid.");
                    } else {
                        ++v0;
                        continue;
                    }
                }
                new a(e.a(arg3, arg5, arg6), arg4, arg6).execute(new Object[0]);
                return;
            } catch (Exception v0_1) {
                return;
            }
        }
        new a(e.a(arg3, arg5, arg6), arg4, arg6).execute(new Object[0]);
        return;
    }

    public static void share(Context arg1, String arg2, UMPlatformData[] arg3) {
        UMSocialService.a(arg1, null, arg2, arg3);
    }

    public static void share(Context context, UMPlatformData[] arg2) {
        UMSocialService.a(context, null, null, arg2);
    }
}

